﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using QASampling.BusinessObject;
using QASampling.QAControl;

namespace QASampling.UI
{
    public partial class frm1111 : BaseForm
    {
        private static string PAGE_1111_A1_TITLE = "Formulir 1111 A1 ";
        private static string PAGE_1111_A2_TITLE = "Formulir 1111 A2 ";
        private static string PAGE_1111_B1_TITLE = "Formulir 1111 B1 ";
        private static string PAGE_1111_B2_TITLE = "Formulir 1111 B2 ";
        private static string PAGE_1111_B3_TITLE = "Formulir 1111 B3 ";
     //   private static string PAGE_1111_AB_TITLE = "Formulir 1111 AB ";

        private static string ORI = "_ori";

        private static string COL_DOC_ID = "DocId";
        private static string COL_NAMA_PEMBELI = "NamaPembeli";
        private static string COL_NOMOR = "Nomor";
        private static string COL_TANGGAL = "Tanggal";
        private static string COL_NPWP = "NPWP";
        private static string COL_KODE_NO_SERI = "Kode dan Nomor Seri";
        private static string COL_DPP = "DPP";
        private static string COL_PPN = "PPN";
        private static string COL_PPNBM = "PPnBM";
        private static string COL_KETERANGAN = "Keterangan";
        private static string COL_ID = "ID";

        private static string COL_DOC_ID_ORI = "DocId" + ORI;
        private static string COL_NAMA_PEMBELI_ORI = "NamaPembeli" + ORI;
        private static string COL_NOMOR_ORI = "Nomor" + ORI;
        private static string COL_TANGGAL_ORI = "Tanggal" + ORI;
        private static string COL_NPWP_ORI = "NPWP" + ORI;
        private static string COL_KODE_NO_SERI_ORI = "Kode dan Nomor Seri" + ORI;
        private static string COL_DPP_ORI = "DPP" + ORI;
        private static string COL_PPN_ORI = "PPN" + ORI;
        private static string COL_PPNBM_ORI = "PPnBM" + ORI;
        private static string COL_KETERANGAN_ORI = "Keterangan" + ORI;

        private Form1111 form;

        public frm1111(string docId) : this()
        {
            this.form = DAO.GetForm1111(docId);
            if (this.form == null)
                throw new Exception("Dokumen dengan DocId: " + docId + " tidak ditemukan");


            txtNamaPKP.Text = form.NamaPkp;
            txtAlamat.Text = form.Alamat;
            txtNPWP.Text = form.Npwp;
            txtMasa.Text = form.MasaPajak;

            txt_Page1_I_A_1.Text = form.I_A_1;
            txt_Page1_I_A_1.OriginalValue = form.I_A_1;
            txt_Page1_I_A_2_DPP.Text = form.I_A_2_DPP;
            txt_Page1_I_A_2_DPP.OriginalValue = form.I_A_2_DPP;
            txt_Page1_I_A_2_PPN.Text = form.I_A_2_PPN;
            txt_Page1_I_A_2_PPN.OriginalValue = form.I_A_2_PPN;
            txt_Page1_I_A_3_DPP.Text = form.I_A_3_DPP;
            txt_Page1_I_A_3_DPP.OriginalValue = form.I_A_3_DPP;
            txt_Page1_I_A_3_PPN.Text = form.I_A_3_PPN;
            txt_Page1_I_A_3_PPN.OriginalValue = form.I_A_3_PPN;
            txt_Page1_I_A_4_DPP.Text = form.I_A_4_DPP;
            txt_Page1_I_A_4_DPP.OriginalValue = form.I_A_4_DPP;
            txt_Page1_I_A_4_PPN.Text = form.I_A_4_PPN;
            txt_Page1_I_A_4_PPN.OriginalValue = form.I_A_4_PPN;
            txt_Page1_I_A_5_DPP.Text = form.I_A_5_DPP;
            txt_Page1_I_A_5_DPP.OriginalValue = form.I_A_5_DPP;
            txt_Page1_I_A_5_PPN.Text = form.I_A_5_PPN;
            txt_Page1_I_A_5_PPN.OriginalValue = form.I_A_5_PPN;
            txt_Page1_I_A_Jml_DPP.Text = form.I_A_Jml_DPP;
            txt_Page1_I_A_Jml_DPP.OriginalValue = form.I_A_Jml_DPP;
            txt_Page1_I_A_Jml_PPN.Text = form.I_A_Jml_PPN;
            txt_Page1_I_A_Jml_PPN.OriginalValue = form.I_A_Jml_PPN;
            txt_Page1_I_B.Text = form.I_B;
            txt_Page1_I_B.OriginalValue = form.I_B;
            txt_Page1_I_C.Text = form.I_C;
            txt_Page1_I_C.OriginalValue = form.I_C;

            txt_Page1_II_A.Text = form.II_A;
            txt_Page1_II_A.OriginalValue = form.II_A;
            txt_Page1_II_B.Text = form.II_B;
            txt_Page1_II_B.OriginalValue = form.II_B;
            txt_Page1_II_C.Text = form.II_C;
            txt_Page1_II_C.OriginalValue = form.II_C;
            txt_Page1_II_D.Text = form.II_D;
            txt_Page1_II_D.OriginalValue = form.II_D;
            txt_Page1_II_E.Text = form.II_E;
            txt_Page1_II_E.OriginalValue = form.II_E;
            txt_Page1_II_F.Text = form.II_F;
            txt_Page1_II_F.OriginalValue = form.II_F;

            txt_Page1_III_A.Text = form.III_A;
            txt_Page1_III_A.OriginalValue = form.III_A;
            txt_Page1_III_B.Text = form.III_B;
            txt_Page1_III_B.OriginalValue = form.III_B;

            txt_Page1_IV_A.Text = form.IV_A;
            txt_Page1_IV_A.OriginalValue = form.IV_A;

            txt_Page1_V_A.Text = form.V_A;
            txt_Page1_V_A.OriginalValue = form.V_A;
            txt_Page1_V_B.Text = form.V_B;
            txt_Page1_V_B.OriginalValue = form.V_B;
            txt_Page1_V_C.Text = form.V_C;
            txt_Page1_V_C.OriginalValue = form.V_C;
            txt_Page1_V_D.Text = form.V_D;
            txt_Page1_V_D.OriginalValue = form.V_D;
            txt_Page1_V_E.Text = form.V_E;
            txt_Page1_V_E.OriginalValue = form.V_E;

            foreach (Form1111_Item i in form.A1_Page.Items)
            {
                string[] values = { i.DocId, i.Nama, i.Nomor, i.Tanggal, i.Dpp, i.Ket,
                                       i.Nama, i.Nomor, i.Tanggal, i.Dpp, i.Ket, i.Id };
                dgv_1111_A1.Rows.Add(values);
            }

            txtTotalDPP_A1.Text = form.A1_Page.TotalDpp;
            txtTotalDPP_A1.OriginalValue = form.A1_Page.TotalDpp;

            foreach (Form1111_Item i in form.A2_Page.Items)
            {
                string[] values = { i.DocId, i.Nama, i.Npwp, i.Kode_no_seri, i.Tanggal, i.Dpp, i.Ppn, i.PPnBM,
                                      i.Nama, i.Npwp, i.Kode_no_seri, i.Tanggal, i.Dpp, i.Ppn, i.PPnBM, i.Id };
                dgv_1111_A2.Rows.Add(values);
            }

            txtTotalDPP_A2.Text = form.A2_Page.TotalDpp;
            txtTotalDPP_A2.OriginalValue = form.A2_Page.TotalDpp;

            txtTotalPPN_A2.Text = form.A2_Page.TotalPpn;
            txtTotalPPN_A2.OriginalValue = form.A2_Page.TotalPpn;

            txtTotalPPnBM_A2.Text = form.A2_Page.TotalPPnBM;
            txtTotalPPnBM_A2.OriginalValue = form.A2_Page.TotalPPnBM;

            foreach (Form1111_Item i in form.B1_Page.Items)
            {
                string[] values = { i.DocId, i.Nama, i.Nomor, i.Tanggal, i.Dpp, i.Ppn, i.PPnBM, i.Ket,
                                      i.Nama, i.Nomor, i.Tanggal, i.Dpp, i.Ppn, i.PPnBM, i.Ket, i.Id };
                dgv_1111_B1.Rows.Add(values);
            }

            txtTotalDPP_B1.Text = form.B1_Page.TotalDpp;
            txtTotalDPP_B1.OriginalValue = form.B1_Page.TotalDpp;

            txtTotalPPN_B1.Text = form.B1_Page.TotalPpn;
            txtTotalPPN_B1.OriginalValue = form.B1_Page.TotalPpn;

            txtTotalPPnBM_B1.Text = form.B1_Page.TotalPPnBM;
            txtTotalPPnBM_B1.OriginalValue = form.B1_Page.TotalPPnBM;

            foreach (Form1111_Item i in form.B2_Page.Items)
            {
                string[] values = { i.DocId, i.Nama, i.Npwp, i.Kode_no_seri, i.Tanggal, i.Dpp, i.Ppn, i.PPnBM,
                                      i.Nama, i.Npwp, i.Kode_no_seri, i.Tanggal, i.Dpp, i.Ppn, i.PPnBM, i.Id };
                dgv_1111_B2.Rows.Add(values);
            }

            txtTotalDPP_B2.Text = form.B2_Page.TotalDpp;
            txtTotalDPP_B2.OriginalValue = form.B2_Page.TotalDpp;

            txtTotalPPN_B2.Text = form.B2_Page.TotalPpn;
            txtTotalPPN_B2.OriginalValue = form.B2_Page.TotalPpn;

            txtTotalPPnBM_B2.Text = form.B2_Page.TotalPPnBM;
            txtTotalPPnBM_B2.OriginalValue = form.B2_Page.TotalPPnBM;

            foreach (Form1111_Item i in form.B3_Page.Items)
            {
                string[] values = { i.DocId, i.Nama, i.Npwp, i.Kode_no_seri, i.Tanggal, i.Dpp, i.Ppn, i.PPnBM,
                                      i.Nama, i.Npwp, i.Kode_no_seri, i.Tanggal, i.Dpp, i.Ppn, i.PPnBM, i.Id };
                dgv_1111_B3.Rows.Add(values);
            }

            txtTotalDPP_B3.Text = form.B3_Page.TotalDpp;
            txtTotalDPP_B3.OriginalValue = form.B3_Page.TotalDpp;

            txtTotalPPN_B3.Text = form.B3_Page.TotalPpn;
            txtTotalPPN_B3.OriginalValue = form.B3_Page.TotalPpn;

            txtTotalPPnBM_B3.Text = form.B3_Page.TotalPPnBM;
            txtTotalPPnBM_B3.OriginalValue = form.B3_Page.TotalPPnBM;

            txt_Page2_I_A.Text = form.I_A2;
            txt_Page2_I_A.OriginalValue = form.I_A2;
            txt_Page2_I_B_1_DPP.Text = form.I_B2_1_DPP;
            txt_Page2_I_B_1_DPP.OriginalValue = form.I_B2_1_DPP;
            txt_Page2_I_B_1_PPN.Text = form.I_B2_1_PPN;
            txt_Page2_I_B_1_PPN.OriginalValue = form.I_B2_1_PPN;
            txt_Page2_I_B_1_PPnBM.Text = form.I_B2_1_PPnBM;
            txt_Page2_I_B_1_PPnBM.OriginalValue = form.I_B2_1_PPnBM;
            txt_Page2_I_B_2_DPP.Text = form.I_B2_2_DPP;
            txt_Page2_I_B_2_DPP.OriginalValue = form.I_B2_2_DPP;
            txt_Page2_I_B_2_PPN.Text = form.I_B2_2_PPN;
            txt_Page2_I_B_2_PPN.OriginalValue = form.I_B2_2_PPN;
            txt_Page2_I_B_2_PPnBM.Text = form.I_B2_2_PPnBM;
            txt_Page2_I_B_2_PPnBM.OriginalValue = form.I_B2_2_PPnBM;
            txt_Page2_I_C_1_DPP.Text = form.I_C2_1_DPP;
            txt_Page2_I_C_1_DPP.OriginalValue = form.I_C2_1_DPP;
            txt_Page2_I_C_1_PPN.Text = form.I_C2_1_PPN;
            txt_Page2_I_C_1_PPN.OriginalValue = form.I_C2_1_PPN;
            txt_Page2_I_C_1_PPnBM.Text = form.I_C2_1_PPnBM;
            txt_Page2_I_C_1_PPnBM.OriginalValue = form.I_C2_1_PPnBM;
            txt_Page2_I_C_2_DPP.Text = form.I_C2_2_DPP;
            txt_Page2_I_C_2_DPP.OriginalValue = form.I_C2_2_DPP;
            txt_Page2_I_C_2_PPN.Text = form.I_C2_2_PPN;
            txt_Page2_I_C_2_PPN.OriginalValue = form.I_C2_2_PPN;
            txt_Page2_I_C_2_PPnBM.Text = form.I_C2_2_PPnBM;
            txt_Page2_I_C_2_PPnBM.OriginalValue = form.I_C2_2_PPnBM;
            txt_Page2_I_C_3_DPP.Text = form.I_C2_3_DPP;
            txt_Page2_I_C_3_DPP.OriginalValue = form.I_C2_3_DPP;
            txt_Page2_I_C_3_PPN.Text = form.I_C2_3_PPN;
            txt_Page2_I_C_3_PPN.OriginalValue = form.I_C2_3_PPN;
            txt_Page2_I_C_3_PPnBM.Text = form.I_C2_3_PPnBM;
            txt_Page2_I_C_3_PPnBM.OriginalValue = form.I_C2_3_PPnBM;
            txt_Page2_I_C_4_DPP.Text = form.I_C2_4_DPP;
            txt_Page2_I_C_4_DPP.OriginalValue = form.I_C2_4_DPP;
            txt_Page2_I_C_4_PPN.Text = form.I_C2_4_PPN;
            txt_Page2_I_C_4_PPN.OriginalValue = form.I_C2_4_PPN;
            txt_Page2_I_C_4_PPnBM.Text = form.I_C2_4_PPnBM;
            txt_Page2_I_C_4_PPnBM.OriginalValue = form.I_C2_4_PPnBM;

            txt_Page2_II_A_DPP.Text = form.II_A2_DPP;
            txt_Page2_II_A_DPP.OriginalValue = form.II_A2_DPP;
            txt_Page2_II_A_PPN.Text = form.II_A2_PPN;
            txt_Page2_II_A_PPN.OriginalValue = form.II_A2_PPN;
            txt_Page2_II_A_PPnBM.Text = form.II_A2_PPnBM;
            txt_Page2_II_A_PPnBM.OriginalValue = form.II_A2_PPnBM;
            txt_Page2_II_B_DPP.Text = form.II_B2_DPP;
            txt_Page2_II_B_DPP.OriginalValue = form.II_B2_DPP;
            txt_Page2_II_B_PPN.Text = form.II_B2_PPN;
            txt_Page2_II_B_PPN.OriginalValue = form.II_B2_PPN;
            txt_Page2_II_B_PPnBM.Text = form.II_B2_PPnBM;
            txt_Page2_II_B_PPnBM.OriginalValue = form.II_B2_PPnBM;
            txt_Page2_II_C_DPP.Text = form.II_C2_DPP;
            txt_Page2_II_C_DPP.OriginalValue = form.II_C2_DPP;
            txt_Page2_II_C_PPN.Text = form.II_C2_PPN;
            txt_Page2_II_C_PPN.OriginalValue = form.II_C2_PPN;
            txt_Page2_II_C_PPnBM.Text = form.II_C2_PPnBM;
            txt_Page2_II_C_PPnBM.OriginalValue = form.II_C2_PPnBM;
            txt_Page2_II_D_DPP.Text = form.II_D2_DPP;
            txt_Page2_II_D_DPP.OriginalValue = form.II_D2_DPP;
            txt_Page2_II_D_PPN.Text = form.II_D2_PPN;
            txt_Page2_II_D_PPN.OriginalValue = form.II_D2_PPN;
            txt_Page2_II_D_PPnBM.Text = form.II_D2_PPnBM;
            txt_Page2_II_D_PPnBM.OriginalValue = form.II_D2_PPnBM;

            txt_Page2_III_A.Text = form.III_A2;
            txt_Page2_III_A.OriginalValue = form.III_A2;
            txt_Page2_III_B_1.Text = form.III_B2_1;
            txt_Page2_III_B_1.OriginalValue = form.III_B2_1;
            txt_Page2_III_B_2.Text = form.III_B2_2;
            txt_Page2_III_B_2.OriginalValue = form.III_B2_2;
            txt_Page2_III_B_3.Text = form.III_B2_3;
            txt_Page2_III_B_3.OriginalValue = form.III_B2_3;
            txt_Page2_III_B_4.Text = form.III_B2_4;
            txt_Page2_III_B_4.OriginalValue = form.III_B2_4;
            txt_Page2_III_C.Text = form.III_C2;
            txt_Page2_III_C.OriginalValue = form.III_C2;
        }

        public frm1111()
        {
            InitializeComponent();
            PopulateDataGridColumns();
        }

        private void PopulateDataGridColumns()
        {
            int idx;

            idx = dgv_1111_A1.Columns.Add(COL_DOC_ID, "Doc Id");
            dgv_1111_A1.Columns[idx].Visible = false;
            dgv_1111_A1.Columns.Add(COL_NAMA_PEMBELI, "Nama Pembeli BKP/Penerima Manfaat BKP Tidak Berwujud/Penerima JKP");
            dgv_1111_A1.Columns[1].Width = 250;
            dgv_1111_A1.Columns.Add(COL_NOMOR, "Nomor");
            dgv_1111_A1.Columns.Add(COL_TANGGAL, "Tanggal");
            dgv_1111_A1.Columns.Add(COL_DPP, "DPP");
            dgv_1111_A1.Columns.Add(COL_KETERANGAN, "Keterangan");

            idx = dgv_1111_A1.Columns.Add(COL_NAMA_PEMBELI_ORI, "Nama Pembeli BKP/Penerima Manfaat BKP Tidak Berwujud/Penerima JKP");
            dgv_1111_A1.Columns[idx].Visible = false;
            idx = dgv_1111_A1.Columns.Add(COL_NOMOR_ORI, "Nomor");
            dgv_1111_A1.Columns[idx].Visible = false;
            idx = dgv_1111_A1.Columns.Add(COL_TANGGAL_ORI, "Tanggal");
            dgv_1111_A1.Columns[idx].Visible = false;
            idx = dgv_1111_A1.Columns.Add(COL_DPP_ORI, "DPP");
            dgv_1111_A1.Columns[idx].Visible = false;
            idx = dgv_1111_A1.Columns.Add(COL_KETERANGAN_ORI, "Keterangan");
            dgv_1111_A1.Columns[idx].Visible = false;
            idx = dgv_1111_A1.Columns.Add(COL_ID, "Id");
            dgv_1111_A1.Columns[idx].Visible = false;



            idx = dgv_1111_A2.Columns.Add(COL_DOC_ID, "Doc Id");
            dgv_1111_A2.Columns[idx].Visible = false;
            dgv_1111_A2.Columns.Add(COL_NAMA_PEMBELI, "Nama Pembeli BKP/Penerima Manfaat BKP Tidak Berwujud/Penerima JKP");
            dgv_1111_A2.Columns[1].Width = 250;
            dgv_1111_A2.Columns.Add(COL_NPWP, "NPWP/Nomor Paspor");
            dgv_1111_A2.Columns.Add(COL_KODE_NO_SERI, "Kode dan Nomor Seri");
            dgv_1111_A2.Columns.Add(COL_TANGGAL, "Tanggal");
            dgv_1111_A2.Columns.Add(COL_DPP, "DPP");
            dgv_1111_A2.Columns.Add(COL_PPN, "PPN");
            dgv_1111_A2.Columns.Add(COL_PPNBM, "PPnBM");

            idx = dgv_1111_A2.Columns.Add(COL_NAMA_PEMBELI_ORI, "Nama Pembeli BKP/Penerima Manfaat BKP Tidak Berwujud/Penerima JKP");
            dgv_1111_A2.Columns[idx].Visible = false;
            idx = dgv_1111_A2.Columns.Add(COL_NPWP_ORI, "NPWP/Nomor Paspor");
            dgv_1111_A2.Columns[idx].Visible = false;
            idx = dgv_1111_A2.Columns.Add(COL_KODE_NO_SERI_ORI, "Kode dan Nomor Seri");
            dgv_1111_A2.Columns[idx].Visible = false;
            idx = dgv_1111_A2.Columns.Add(COL_TANGGAL_ORI, "Tanggal");
            dgv_1111_A2.Columns[idx].Visible = false;
            idx = dgv_1111_A2.Columns.Add(COL_DPP_ORI, "DPP");
            dgv_1111_A2.Columns[idx].Visible = false;
            idx = dgv_1111_A2.Columns.Add(COL_PPN_ORI, "PPN");
            dgv_1111_A2.Columns[idx].Visible = false;
            idx = dgv_1111_A2.Columns.Add(COL_PPNBM_ORI, "PPnBM");
            dgv_1111_A2.Columns[idx].Visible = false;
            idx = dgv_1111_A2.Columns.Add(COL_ID, "Id");
            dgv_1111_A2.Columns[idx].Visible = false;



            idx = dgv_1111_B1.Columns.Add(COL_DOC_ID, "Doc Id");
            dgv_1111_B1.Columns[idx].Visible = false;
            dgv_1111_B1.Columns.Add(COL_NAMA_PEMBELI, "Nama Penjual BKP/BKP Tidak Berwujud/Pemberi JKP");
            dgv_1111_B1.Columns[1].Width = 250;
            dgv_1111_B1.Columns.Add(COL_NOMOR, "Nomor");
            dgv_1111_B1.Columns.Add(COL_TANGGAL, "Tanggal");
            dgv_1111_B1.Columns.Add(COL_DPP, "DPP");
            dgv_1111_B1.Columns.Add(COL_PPN, "PPN");
            dgv_1111_B1.Columns.Add(COL_PPNBM, "PPnBM");
            dgv_1111_B1.Columns.Add(COL_KETERANGAN, "Keterangan");

            idx = dgv_1111_B1.Columns.Add(COL_NAMA_PEMBELI_ORI, "Nama Penjual BKP/BKP Tidak Berwujud/Pemberi JKP");
            dgv_1111_B1.Columns[idx].Visible = false;
            idx = dgv_1111_B1.Columns.Add(COL_NOMOR_ORI, "Nomor");
            dgv_1111_B1.Columns[idx].Visible = false;
            idx = dgv_1111_B1.Columns.Add(COL_TANGGAL_ORI, "Tanggal");
            dgv_1111_B1.Columns[idx].Visible = false;
            idx = dgv_1111_B1.Columns.Add(COL_DPP_ORI, "DPP");
            dgv_1111_B1.Columns[idx].Visible = false;
            idx = dgv_1111_B1.Columns.Add(COL_PPN_ORI, "PPN");
            dgv_1111_B1.Columns[idx].Visible = false;
            idx = dgv_1111_B1.Columns.Add(COL_PPNBM_ORI, "PPnBM");
            dgv_1111_B1.Columns[idx].Visible = false;
            idx = dgv_1111_B1.Columns.Add(COL_KETERANGAN_ORI, "Keterangan");
            dgv_1111_B1.Columns[idx].Visible = false;
            idx = dgv_1111_B1.Columns.Add(COL_ID, "Id");
            dgv_1111_B1.Columns[idx].Visible = false;



            idx = dgv_1111_B2.Columns.Add(COL_DOC_ID, "Doc Id");
            dgv_1111_B2.Columns[idx].Visible = false;
            dgv_1111_B2.Columns.Add(COL_NAMA_PEMBELI, "Nama Penjual BKP/BKP Tidak Berwujud/Pemberi JKP");
            dgv_1111_B2.Columns[1].Width = 250;
            dgv_1111_B2.Columns.Add(COL_NPWP, "NPWP");
            dgv_1111_B2.Columns.Add(COL_KODE_NO_SERI, "Kode dan Nomor Seri");
            dgv_1111_B2.Columns.Add(COL_TANGGAL, "Tanggal");
            dgv_1111_B2.Columns.Add(COL_DPP, "DPP");
            dgv_1111_B2.Columns.Add(COL_PPN, "PPN");
            dgv_1111_B2.Columns.Add(COL_PPNBM, "PPnBM");

            idx = dgv_1111_B2.Columns.Add(COL_NAMA_PEMBELI_ORI, "Nama Penjual BKP/BKP Tidak Berwujud/Pemberi JKP");
            dgv_1111_B2.Columns[idx].Visible = false;
            idx = dgv_1111_B2.Columns.Add(COL_NPWP_ORI, "NPWP");
            dgv_1111_B2.Columns[idx].Visible = false;
            idx = dgv_1111_B2.Columns.Add(COL_KODE_NO_SERI_ORI, "Kode dan Nomor Seri");
            dgv_1111_B2.Columns[idx].Visible = false;
            idx = dgv_1111_B2.Columns.Add(COL_TANGGAL_ORI, "Tanggal");
            dgv_1111_B2.Columns[idx].Visible = false;
            idx = dgv_1111_B2.Columns.Add(COL_DPP_ORI, "DPP");
            dgv_1111_B2.Columns[idx].Visible = false;
            idx = dgv_1111_B2.Columns.Add(COL_PPN_ORI, "PPN");
            dgv_1111_B2.Columns[idx].Visible = false;
            idx = dgv_1111_B2.Columns.Add(COL_PPNBM_ORI, "PPnBM");
            dgv_1111_B2.Columns[idx].Visible = false;
            idx = dgv_1111_B2.Columns.Add(COL_ID, "Id");
            dgv_1111_B2.Columns[idx].Visible = false;



            idx = dgv_1111_B3.Columns.Add(COL_DOC_ID, "Doc Id");
            dgv_1111_B3.Columns[idx].Visible = false;
            dgv_1111_B3.Columns.Add(COL_NAMA_PEMBELI, "Nama Penjual BKP/BKP Tidak Berwujud/Pemberi JKP");
            dgv_1111_B3.Columns[1].Width = 250;
            dgv_1111_B3.Columns.Add(COL_NPWP, "NPWP");
            dgv_1111_B3.Columns.Add(COL_KODE_NO_SERI, "Kode dan Nomor Seri");
            dgv_1111_B3.Columns.Add(COL_TANGGAL, "Tanggal");
            dgv_1111_B3.Columns.Add(COL_DPP, "DPP");
            dgv_1111_B3.Columns.Add(COL_PPN, "PPN");
            dgv_1111_B3.Columns.Add(COL_PPNBM, "PPnBM");

            idx = dgv_1111_B3.Columns.Add(COL_NAMA_PEMBELI_ORI, "Nama Penjual BKP/BKP Tidak Berwujud/Pemberi JKP");
            dgv_1111_B3.Columns[idx].Visible = false;
            idx = dgv_1111_B3.Columns.Add(COL_NPWP_ORI, "NPWP");
            dgv_1111_B3.Columns[idx].Visible = false;
            idx = dgv_1111_B3.Columns.Add(COL_KODE_NO_SERI_ORI, "Kode dan Nomor Seri");
            dgv_1111_B3.Columns[idx].Visible = false;
            idx = dgv_1111_B3.Columns.Add(COL_TANGGAL_ORI, "Tanggal");
            dgv_1111_B3.Columns[idx].Visible = false;
            idx = dgv_1111_B3.Columns.Add(COL_DPP_ORI, "DPP");
            dgv_1111_B3.Columns[idx].Visible = false;
            idx = dgv_1111_B3.Columns.Add(COL_PPN_ORI, "PPN");
            dgv_1111_B3.Columns[idx].Visible = false;
            idx = dgv_1111_B3.Columns.Add(COL_PPNBM_ORI, "PPnBM");
            dgv_1111_B3.Columns[idx].Visible = false;
            idx = dgv_1111_B3.Columns.Add(COL_ID, "Id");
            dgv_1111_B3.Columns[idx].Visible = false;
        }

        private void dgv_1111_A1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dgv_1111_A1.SelectedRows.Count == 0) return;

            DataGridViewRow row = dgv_1111_A1.SelectedRows[0];
            frm1111DM_A_R frm = new frm1111DM_A_R();
            frm.lblFormulirName.Text = "Formulir 1111";
            frm.txtPpn.Visible = false;
            frm.txtPPnBM.Visible = false;
            frm.label5.Visible = false;
            frm.label6.Visible = false;
            frm.txtDocId.Text = row.Cells[COL_DOC_ID].Value.ToString();
            frm.txtNama.Text = row.Cells[COL_NAMA_PEMBELI].Value.ToString();
            frm.txtNPWP.Text = row.Cells[COL_NPWP].Value.ToString();
            frm.txtDpp.Text = row.Cells[COL_DPP].Value.ToString();
     //       frm.txtPpn.Text = row.Cells[COL_PPN].Value.ToString();
       //     frm.txtPPnBM.Text = row.Cells[COL_PPNBM].Value.ToString();

            frm.txtDpp.OriginalValue = row.Cells[COL_DPP_ORI].Value.ToString();
         //   frm.txtPpn.OriginalValue = row.Cells[COL_PPN_ORI].Value.ToString();
           // frm.txtPPnBM.OriginalValue = row.Cells[COL_PPNBM_ORI].Value.ToString();

            frm.Text = PAGE_1111_A1_TITLE;

            if (frm.ShowDialog() == DialogResult.OK)
            {
                row.Cells[COL_DPP].Value = frm.txtDpp.Text;
             //   row.Cells[COL_PPN].Value = frm.txtPpn.Text;
               // row.Cells[COL_PPNBM].Value = frm.txtPPnBM.Text;

                row.Cells[COL_DPP_ORI].Value = frm.txtDpp.OriginalValue;
               // row.Cells[COL_PPN_ORI].Value = frm.txtPpn.OriginalValue;
                //row.Cells[COL_PPNBM_ORI].Value = frm.txtPPnBM.OriginalValue;

                SetDataGridBackgroundColor(dgv_1111_A1,5);
            }
        }

        private void dgv_1111_A2_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dgv_1111_A2.SelectedRows.Count == 0) return;

            DataGridViewRow row = dgv_1111_A2.SelectedRows[0];
            frm1111DM_A_R frm = new frm1111DM_A_R();
            frm.lblFormulirName.Text = "Formulir 1111";
            frm.txtDocId.Text = row.Cells[COL_DOC_ID].Value.ToString();
            frm.txtNama.Text = row.Cells[COL_NAMA_PEMBELI].Value.ToString();
            frm.txtNPWP.Text = row.Cells[COL_NPWP].Value.ToString();
            frm.txtDpp.Text = row.Cells[COL_DPP].Value.ToString();
            frm.txtPpn.Text = row.Cells[COL_PPN].Value.ToString();
            frm.txtPPnBM.Text = row.Cells[COL_PPNBM].Value.ToString();

            frm.txtDpp.OriginalValue = row.Cells[COL_DPP_ORI].Value.ToString();
            frm.txtPpn.OriginalValue = row.Cells[COL_PPN_ORI].Value.ToString();
            frm.txtPPnBM.OriginalValue = row.Cells[COL_PPNBM_ORI].Value.ToString();

            frm.Text = PAGE_1111_A2_TITLE;

            if (frm.ShowDialog() == DialogResult.OK)
            {
                row.Cells[COL_DPP].Value = frm.txtDpp.Text;
                row.Cells[COL_PPN].Value = frm.txtPpn.Text;
                row.Cells[COL_PPNBM].Value = frm.txtPPnBM.Text;

                row.Cells[COL_DPP_ORI].Value = frm.txtDpp.OriginalValue;
                row.Cells[COL_PPN_ORI].Value = frm.txtPpn.OriginalValue;
                row.Cells[COL_PPNBM_ORI].Value = frm.txtPPnBM.OriginalValue;

                SetDataGridBackgroundColor(dgv_1111_A2,7);
            }
        }

        private void dgv_1111_B1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dgv_1111_B1.SelectedRows.Count == 0) return;

            DataGridViewRow row = dgv_1111_B1.SelectedRows[0];
            frm1111DM_A_R frm = new frm1111DM_A_R();
            frm.lblFormulirName.Text = "Formulir 1111";
            frm.txtDocId.Text = row.Cells[COL_DOC_ID].Value.ToString();
            frm.txtNama.Text = row.Cells[COL_NAMA_PEMBELI].Value.ToString();
            frm.txtNPWP.Text = row.Cells[COL_NPWP].Value.ToString();
            frm.txtDpp.Text = row.Cells[COL_DPP].Value.ToString();
            frm.txtPpn.Text = row.Cells[COL_PPN].Value.ToString();
            frm.txtPPnBM.Text = row.Cells[COL_PPNBM].Value.ToString();

            frm.txtDpp.OriginalValue = row.Cells[COL_DPP_ORI].Value.ToString();
            frm.txtPpn.OriginalValue = row.Cells[COL_PPN_ORI].Value.ToString();
            frm.txtPPnBM.OriginalValue = row.Cells[COL_PPNBM_ORI].Value.ToString();

            frm.Text = PAGE_1111_B1_TITLE;

            if (frm.ShowDialog() == DialogResult.OK)
            {
                row.Cells[COL_DPP].Value = frm.txtDpp.Text;
                row.Cells[COL_PPN].Value = frm.txtPpn.Text;
                row.Cells[COL_PPNBM].Value = frm.txtPPnBM.Text;

                row.Cells[COL_DPP_ORI].Value = frm.txtDpp.OriginalValue;
                row.Cells[COL_PPN_ORI].Value = frm.txtPpn.OriginalValue;
                row.Cells[COL_PPNBM_ORI].Value = frm.txtPPnBM.OriginalValue;

                SetDataGridBackgroundColor(dgv_1111_B1,6);
            }
        }

        private void dgv_1111_B2_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dgv_1111_B2.SelectedRows.Count == 0) return;

            DataGridViewRow row = dgv_1111_B2.SelectedRows[0];
            frm1111DM_A_R frm = new frm1111DM_A_R();
            frm.lblFormulirName.Text = "Formulir 1111";
            frm.txtDocId.Text = row.Cells[COL_DOC_ID].Value.ToString();
            frm.txtNama.Text = row.Cells[COL_NAMA_PEMBELI].Value.ToString();
            frm.txtNPWP.Text = row.Cells[COL_NPWP].Value.ToString();
            frm.txtDpp.Text = row.Cells[COL_DPP].Value.ToString();
            frm.txtPpn.Text = row.Cells[COL_PPN].Value.ToString();
            frm.txtPPnBM.Text = row.Cells[COL_PPNBM].Value.ToString();

            frm.txtDpp.OriginalValue = row.Cells[COL_DPP_ORI].Value.ToString();
            frm.txtPpn.OriginalValue = row.Cells[COL_PPN_ORI].Value.ToString();
            frm.txtPPnBM.OriginalValue = row.Cells[COL_PPNBM_ORI].Value.ToString();

            frm.Text = PAGE_1111_B2_TITLE;

            if (frm.ShowDialog() == DialogResult.OK)
            {
                row.Cells[COL_DPP].Value = frm.txtDpp.Text;
                row.Cells[COL_PPN].Value = frm.txtPpn.Text;
                row.Cells[COL_PPNBM].Value = frm.txtPPnBM.Text;

                row.Cells[COL_DPP_ORI].Value = frm.txtDpp.OriginalValue;
                row.Cells[COL_PPN_ORI].Value = frm.txtPpn.OriginalValue;
                row.Cells[COL_PPNBM_ORI].Value = frm.txtPPnBM.OriginalValue;

                SetDataGridBackgroundColor(dgv_1111_B2,7);
            }
        }

        private void dgv_1111_B3_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dgv_1111_B3.SelectedRows.Count == 0) return;

            DataGridViewRow row = dgv_1111_B3.SelectedRows[0];
            frm1111DM_A_R frm = new frm1111DM_A_R();
            frm.lblFormulirName.Text = "Formulir 1111";
            frm.txtDocId.Text = row.Cells[COL_DOC_ID].Value.ToString();
            frm.txtNama.Text = row.Cells[COL_NAMA_PEMBELI].Value.ToString();
            frm.txtNPWP.Text = row.Cells[COL_NPWP].Value.ToString();
            frm.txtDpp.Text = row.Cells[COL_DPP].Value.ToString();
            frm.txtPpn.Text = row.Cells[COL_PPN].Value.ToString();
            frm.txtPPnBM.Text = row.Cells[COL_PPNBM].Value.ToString();

            frm.txtDpp.OriginalValue = row.Cells[COL_DPP_ORI].Value.ToString();
            frm.txtPpn.OriginalValue = row.Cells[COL_PPN_ORI].Value.ToString();
            frm.txtPPnBM.OriginalValue = row.Cells[COL_PPNBM_ORI].Value.ToString();

            frm.Text = PAGE_1111_B3_TITLE;

            if (frm.ShowDialog() == DialogResult.OK)
            {
                row.Cells[COL_DPP].Value = frm.txtDpp.Text;
                row.Cells[COL_PPN].Value = frm.txtPpn.Text;
                row.Cells[COL_PPNBM].Value = frm.txtPPnBM.Text;

                row.Cells[COL_DPP_ORI].Value = frm.txtDpp.OriginalValue;
                row.Cells[COL_PPN_ORI].Value = frm.txtPpn.OriginalValue;
                row.Cells[COL_PPNBM_ORI].Value = frm.txtPPnBM.OriginalValue;

                SetDataGridBackgroundColor(dgv_1111_B3,7);
            }
        }

        private void btnBatal_Click(object sender, EventArgs e)
        {
            string msg = "Anda yakin akan membatalkan proses koreksi?";
            if (MessageBox.Show(msg, this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Yes)
                this.Close();
        }

        private void btnSimpan_Click(object sender, EventArgs e)
        {
            string msg = "Anda yakin akan menyimpan koreksi yang telah Anda lakukan?";
            if (MessageBox.Show(msg, this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Yes)
            {
                if (ValidateForm())
                    SaveData();
            }
        }

        private bool ValidateForm()
        {
            bool a = true;
            if (String.IsNullOrEmpty(txt_Page1_I_A_1.Text) ||
               (!String.IsNullOrEmpty(txt_Page2_I_A.Text) &&
               long.Parse(txt_Page1_I_A_1.Text) != long.Parse(txt_Page2_I_A.Text)) ||
               (!String.IsNullOrEmpty(txtTotalDPP_A1.Text) &&
               long.Parse(txt_Page1_I_A_1.Text) != long.Parse(txtTotalDPP_A1.Text)))
            {
                txt_Page1_I_A_1.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page1_I_A_2_DPP.Text) ||
               (!String.IsNullOrEmpty(txt_Page2_I_C_1_DPP.Text) &&
               long.Parse(txt_Page1_I_A_2_DPP.Text) != long.Parse(txt_Page2_I_C_1_DPP.Text)))
            {
                txt_Page1_I_A_2_DPP.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page1_I_A_2_PPN.Text) ||
               (!String.IsNullOrEmpty(txt_Page2_I_C_1_PPN.Text) &&
               long.Parse(txt_Page1_I_A_2_PPN.Text) != long.Parse(txt_Page2_I_C_1_PPN.Text)))
            {
                txt_Page1_I_A_2_PPN.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page1_I_A_3_DPP.Text) ||
               (!String.IsNullOrEmpty(txt_Page2_I_C_2_DPP.Text) &&
               long.Parse(txt_Page1_I_A_3_DPP.Text) != long.Parse(txt_Page2_I_C_2_DPP.Text)))
            {
                txt_Page1_I_A_3_DPP.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page1_I_A_3_PPN.Text) ||
               (!String.IsNullOrEmpty(txt_Page2_I_C_2_PPN.Text) &&
               long.Parse(txt_Page1_I_A_3_PPN.Text) != long.Parse(txt_Page2_I_C_2_PPN.Text)))
            {
                txt_Page1_I_A_3_PPN.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page1_I_A_4_DPP.Text) ||
               (!String.IsNullOrEmpty(txt_Page2_I_C_3_DPP.Text) &&
               long.Parse(txt_Page1_I_A_4_DPP.Text) != long.Parse(txt_Page2_I_C_3_DPP.Text)))
            {
                txt_Page1_I_A_4_DPP.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page1_I_A_4_PPN.Text) ||
               (!String.IsNullOrEmpty(txt_Page2_I_C_3_PPN.Text) &&
               long.Parse(txt_Page1_I_A_4_PPN.Text) != long.Parse(txt_Page2_I_C_3_PPN.Text)))
            {
                txt_Page1_I_A_4_PPN.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page1_I_A_5_DPP.Text) ||
               (!String.IsNullOrEmpty(txt_Page2_I_C_4_DPP.Text) &&
               long.Parse(txt_Page1_I_A_5_DPP.Text) != long.Parse(txt_Page2_I_C_4_DPP.Text)))
            {
                txt_Page1_I_A_5_DPP.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page1_I_A_5_PPN.Text) ||
               (!String.IsNullOrEmpty(txt_Page2_I_C_4_PPN.Text) &&
               long.Parse(txt_Page1_I_A_5_PPN.Text) != long.Parse(txt_Page2_I_C_4_PPN.Text)))
            {
                txt_Page1_I_A_5_PPN.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page1_I_A_Jml_DPP.Text) || 
               (!String.IsNullOrEmpty(txt_Page1_I_A_1.Text) && !String.IsNullOrEmpty(txt_Page1_I_A_2_DPP.Text) && !String.IsNullOrEmpty(txt_Page1_I_A_3_DPP.Text) &&
               !String.IsNullOrEmpty(txt_Page1_I_A_4_DPP.Text) && !String.IsNullOrEmpty(txt_Page1_I_A_5_DPP.Text) &&
               long.Parse(txt_Page1_I_A_Jml_DPP.Text) != long.Parse(txt_Page1_I_A_1.Text) + long.Parse(txt_Page1_I_A_2_DPP.Text) +
               long.Parse(txt_Page1_I_A_3_DPP.Text) + long.Parse(txt_Page1_I_A_4_DPP.Text) +  long.Parse(txt_Page1_I_A_5_DPP.Text)))
            {
                txt_Page1_I_A_Jml_DPP.BackColor = Color.Red;
                a = false;
            }
            else
                txt_Page1_I_A_Jml_DPP.BackColor = Color.White;

            if (String.IsNullOrEmpty(txt_Page1_I_A_Jml_PPN.Text) ||
               (!String.IsNullOrEmpty(txt_Page1_I_A_2_PPN.Text) && !String.IsNullOrEmpty(txt_Page1_I_A_3_PPN.Text) &&
               !String.IsNullOrEmpty(txt_Page1_I_A_4_PPN.Text) && !String.IsNullOrEmpty(txt_Page1_I_A_5_PPN.Text) &&
               long.Parse(txt_Page1_I_A_Jml_PPN.Text) != long.Parse(txt_Page1_I_A_2_PPN.Text) +
               long.Parse(txt_Page1_I_A_3_PPN.Text) +long.Parse(txt_Page1_I_A_4_PPN.Text) + long.Parse(txt_Page1_I_A_5_PPN.Text)))
            {
                txt_Page1_I_A_Jml_PPN.BackColor = Color.Red;
                a = false;
            }
            else
                txt_Page1_I_A_Jml_PPN.BackColor = Color.White;

            if (String.IsNullOrEmpty(txt_Page1_I_B.Text))
            {
                txt_Page1_I_B.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page1_I_C.Text) ||
               (!String.IsNullOrEmpty(txt_Page1_I_A_Jml_DPP.Text) && !String.IsNullOrEmpty(txt_Page1_I_B.Text) &&
               long.Parse(txt_Page1_I_C.Text) != long.Parse(txt_Page1_I_A_Jml_DPP.Text) + long.Parse(txt_Page1_I_B.Text)))
            {
                txt_Page1_I_C.BackColor = Color.Red;
                a = false;
            }
            else
                txt_Page1_I_C.BackColor = Color.White;

            if (String.IsNullOrEmpty(txt_Page1_II_A.Text) || (!String.IsNullOrEmpty(txt_Page1_I_A_2_PPN.Text) &&
               long.Parse(txt_Page1_II_A.Text) != long.Parse(txt_Page1_I_A_2_PPN.Text)))
            {
                txt_Page1_II_A.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page1_II_B.Text))
            {
                txt_Page1_II_B.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page1_II_C.Text) ||
               (!String.IsNullOrEmpty(txt_Page2_III_C.Text) &&
               long.Parse(txt_Page1_II_C.Text) != long.Parse(txt_Page2_III_C.Text)))
            {
                txt_Page1_II_C.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page1_II_D.Text)||
               (!String.IsNullOrEmpty(txt_Page1_II_A.Text) && !String.IsNullOrEmpty(txt_Page1_II_B.Text) &&
               !String.IsNullOrEmpty(txt_Page1_II_C.Text) &&
               long.Parse(txt_Page1_II_D.Text) != long.Parse(txt_Page1_II_A.Text) - long.Parse(txt_Page1_II_B.Text)
               - long.Parse(txt_Page1_II_C.Text)))
            {
                txt_Page1_II_D.BackColor = Color.Red;
                a = false;
            }
            else
                txt_Page1_II_D.BackColor = Color.White;

            if (String.IsNullOrEmpty(txt_Page1_II_E.Text))
            {
                txt_Page1_II_E.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page1_II_F.Text)||
               (!String.IsNullOrEmpty(txt_Page1_II_D.Text) && !String.IsNullOrEmpty(txt_Page1_II_E.Text) &&
               long.Parse(txt_Page1_II_F.Text) != long.Parse(txt_Page1_II_D.Text) - long.Parse(txt_Page1_II_E.Text)))
            {
                txt_Page1_II_F.BackColor = Color.Red;
                a = false;
            }
            else
                txt_Page1_II_F.BackColor = Color.White;

            if (String.IsNullOrEmpty(txt_Page1_III_A.Text))
            {
                txt_Page1_III_A.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page1_III_B.Text))
            {
                txt_Page1_III_B.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page1_IV_A.Text))
            {
                txt_Page1_IV_A.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page1_V_A.Text))
            {
                txt_Page1_V_A.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page1_V_B.Text))
            {
                txt_Page1_V_B.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page1_V_C.Text)||
               (!String.IsNullOrEmpty(txt_Page1_V_A.Text) && !String.IsNullOrEmpty(txt_Page1_V_B.Text) &&
               long.Parse(txt_Page1_V_C.Text) != long.Parse(txt_Page1_V_A.Text) - long.Parse(txt_Page1_V_B.Text)))
            {
                txt_Page1_V_C.BackColor = Color.Red;
                a = false;
            }
            else
                txt_Page1_V_C.BackColor = Color.White;

            if (String.IsNullOrEmpty(txt_Page1_V_D.Text))
            {
                txt_Page1_V_D.BackColor = Color.Red;
                 a = false;
            }
            if (String.IsNullOrEmpty(txt_Page1_V_E.Text)||
               (!String.IsNullOrEmpty(txt_Page1_V_C.Text) && !String.IsNullOrEmpty(txt_Page1_V_D.Text) &&
               long.Parse(txt_Page1_V_E.Text) != long.Parse(txt_Page1_V_C.Text) - long.Parse(txt_Page1_V_D.Text)))
            {
                txt_Page1_V_E.BackColor = Color.Red;
                a = false;
            }
            else
                txt_Page1_V_E.BackColor = Color.White;

            long dpp = 0;
            long dpp1 = 0;
            long ppn1 = 0;
            long ppnbm1 = 0;
            long dpp2 = 0;
            long ppn2 = 0;
            long ppnbm2 = 0;
            long dpp3 = 0;
            long ppn3 = 0;
            long ppnbm3 = 0;
            long dpp4 = 0;
            long ppn4 = 0;
            long ppnbm4 = 0;
            long jml1_dpp = 0;
            long jml1_ppn = 0;
            long jml1_ppnbm = 0;
            long jml2_dpp = 0;
            long jml2_ppn = 0;
            long jml2_ppnbm = 0;
            long jml3_dpp = 0;
            long jml3_ppn = 0;
            long jml3_ppnbm = 0;
            long jml4_dpp = 0;
            long jml4_ppn = 0;
            long jml4_ppnbm = 0;

            for (int i = 0; i <= dgv_1111_A1.RowCount - 1; i++)
            {
                dpp += String.IsNullOrEmpty(dgv_1111_A1.Rows[i].Cells[4].Value.ToString()) ? 0 : long.Parse(dgv_1111_A1.Rows[i].Cells[4].Value.ToString());
            }

            if (String.IsNullOrEmpty(txtTotalDPP_A1.Text) || long.Parse(txtTotalDPP_A1.Text) != dpp)
            {
                txtTotalDPP_A1.BackColor = Color.Red;
                a = false;
            }
            else
                txtTotalDPP_A1.BackColor = Color.White;

            string kode = "";
            for (int i = 0; i <= dgv_1111_A2.RowCount - 1; i++)
            {
                dpp1 += String.IsNullOrEmpty(dgv_1111_A2.Rows[i].Cells[5].Value.ToString()) ? 0 : long.Parse(dgv_1111_A2.Rows[i].Cells[5].Value.ToString());
                ppn1 += String.IsNullOrEmpty(dgv_1111_A2.Rows[i].Cells[6].Value.ToString()) ? 0 : long.Parse(dgv_1111_A2.Rows[i].Cells[6].Value.ToString());
                ppnbm1 += String.IsNullOrEmpty(dgv_1111_A2.Rows[i].Cells[7].Value.ToString()) ? 0 : long.Parse(dgv_1111_A2.Rows[i].Cells[7].Value.ToString());
                kode = String.IsNullOrEmpty(dgv_1111_A2.Rows[i].Cells[3].Value.ToString()) ? "" : dgv_1111_A2.Rows[i].Cells[3].Value.ToString();
                kode = kode.Substring(0,2);
                if (kode == "01" || kode == "04" || kode == "06" || kode == "09")
                {
                    jml1_dpp += String.IsNullOrEmpty(dgv_1111_A2.Rows[i].Cells[5].Value.ToString()) ? 0 : long.Parse(dgv_1111_A2.Rows[i].Cells[5].Value.ToString());
                    jml1_ppn += String.IsNullOrEmpty(dgv_1111_A2.Rows[i].Cells[6].Value.ToString()) ? 0 : long.Parse(dgv_1111_A2.Rows[i].Cells[6].Value.ToString());
                    jml1_ppnbm += String.IsNullOrEmpty(dgv_1111_A2.Rows[i].Cells[7].Value.ToString()) ? 0 : long.Parse(dgv_1111_A2.Rows[i].Cells[7].Value.ToString());
                }
                else if (kode == "02" || kode == "03")
                {
                    jml2_dpp += String.IsNullOrEmpty(dgv_1111_A2.Rows[i].Cells[5].Value.ToString()) ? 0 : long.Parse(dgv_1111_A2.Rows[i].Cells[5].Value.ToString());
                    jml2_ppn += String.IsNullOrEmpty(dgv_1111_A2.Rows[i].Cells[6].Value.ToString()) ? 0 : long.Parse(dgv_1111_A2.Rows[i].Cells[6].Value.ToString());
                    jml2_ppnbm += String.IsNullOrEmpty(dgv_1111_A2.Rows[i].Cells[7].Value.ToString()) ? 0 : long.Parse(dgv_1111_A2.Rows[i].Cells[7].Value.ToString());
                }
                else if (kode == "07")
                {
                    jml3_dpp += String.IsNullOrEmpty(dgv_1111_A2.Rows[i].Cells[5].Value.ToString()) ? 0 : long.Parse(dgv_1111_A2.Rows[i].Cells[5].Value.ToString());
                    jml3_ppn += String.IsNullOrEmpty(dgv_1111_A2.Rows[i].Cells[6].Value.ToString()) ? 0 : long.Parse(dgv_1111_A2.Rows[i].Cells[6].Value.ToString());
                    jml3_ppnbm += String.IsNullOrEmpty(dgv_1111_A2.Rows[i].Cells[7].Value.ToString()) ? 0 : long.Parse(dgv_1111_A2.Rows[i].Cells[7].Value.ToString());
                }
                else if (kode == "08")
                {
                    jml4_dpp += String.IsNullOrEmpty(dgv_1111_A2.Rows[i].Cells[5].Value.ToString()) ? 0 : long.Parse(dgv_1111_A2.Rows[i].Cells[5].Value.ToString());
                    jml4_ppn += String.IsNullOrEmpty(dgv_1111_A2.Rows[i].Cells[6].Value.ToString()) ? 0 : long.Parse(dgv_1111_A2.Rows[i].Cells[6].Value.ToString());
                    jml4_ppnbm += String.IsNullOrEmpty(dgv_1111_A2.Rows[i].Cells[7].Value.ToString()) ? 0 : long.Parse(dgv_1111_A2.Rows[i].Cells[7].Value.ToString());
                }
            }

            if (String.IsNullOrEmpty(txtTotalDPP_A2.Text) || long.Parse(txtTotalDPP_A2.Text) != dpp1)
            {
                txtTotalDPP_A2.BackColor = Color.Red;
                a = false;
            }
            else
                txtTotalDPP_A2.BackColor = Color.White;

            if (String.IsNullOrEmpty(txtTotalPPN_A2.Text) || long.Parse(txtTotalPPN_A2.Text) != ppn1)
            {
                txtTotalPPN_A2.BackColor = Color.Red;
                a = false;
            }
            else
                txtTotalPPN_A2.BackColor = Color.White;

            if (String.IsNullOrEmpty(txtTotalPPnBM_A2.Text) || long.Parse(txtTotalPPnBM_A2.Text) != ppnbm1)
            {
                txtTotalPPnBM_A2.BackColor = Color.Red;
                a = false;
            }
            else
                txtTotalPPnBM_A2.BackColor = Color.White;

            for (int i = 0; i <= dgv_1111_B1.RowCount - 1; i++)
            {
                dpp2 += String.IsNullOrEmpty(dgv_1111_B1.Rows[i].Cells[4].Value.ToString()) ? 0 : long.Parse(dgv_1111_B1.Rows[i].Cells[4].Value.ToString());
                ppn2 += String.IsNullOrEmpty(dgv_1111_B1.Rows[i].Cells[5].Value.ToString()) ? 0 : long.Parse(dgv_1111_B1.Rows[i].Cells[5].Value.ToString());
                ppnbm2 += String.IsNullOrEmpty(dgv_1111_B1.Rows[i].Cells[6].Value.ToString()) ? 0 : long.Parse(dgv_1111_B1.Rows[i].Cells[6].Value.ToString());
            }

            if (String.IsNullOrEmpty(txtTotalDPP_B1.Text) || long.Parse(txtTotalDPP_B1.Text) != dpp2)
            {
                txtTotalDPP_B1.BackColor = Color.Red;
                a = false;
            }
            else
                txtTotalDPP_B1.BackColor = Color.White;

            if (String.IsNullOrEmpty(txtTotalPPN_B1.Text) || long.Parse(txtTotalPPN_B1.Text) != ppn2)
            {
                txtTotalPPN_B1.BackColor = Color.Red;
                a = false;
            }
            else
                txtTotalPPN_B1.BackColor = Color.White;

            if (String.IsNullOrEmpty(txtTotalPPnBM_B1.Text) || long.Parse(txtTotalPPnBM_B1.Text) != ppnbm2)
            {
                txtTotalPPnBM_B1.BackColor = Color.Red;
                a = false;
            }
            else
                txtTotalPPnBM_B1.BackColor = Color.White;

            for (int i = 0; i <= dgv_1111_B2.RowCount - 1; i++)
            {
                dpp3 += String.IsNullOrEmpty(dgv_1111_B2.Rows[i].Cells[5].Value.ToString()) ? 0 : long.Parse(dgv_1111_B2.Rows[i].Cells[5].Value.ToString());
                ppn3 += String.IsNullOrEmpty(dgv_1111_B2.Rows[i].Cells[6].Value.ToString()) ? 0 : long.Parse(dgv_1111_B2.Rows[i].Cells[6].Value.ToString());
                ppnbm3 += String.IsNullOrEmpty(dgv_1111_B2.Rows[i].Cells[7].Value.ToString()) ? 0 : long.Parse(dgv_1111_B2.Rows[i].Cells[7].Value.ToString());
            }

            if (String.IsNullOrEmpty(txtTotalDPP_B2.Text) || long.Parse(txtTotalDPP_B2.Text) != dpp3)
            {
                txtTotalDPP_B2.BackColor = Color.Red;
                a = false;
            }
            else
                txtTotalDPP_B2.BackColor = Color.White;

            if (String.IsNullOrEmpty(txtTotalPPN_B2.Text) || long.Parse(txtTotalPPN_B2.Text) != ppn3)
            {
                txtTotalPPN_B2.BackColor = Color.Red;
                a = false;
            }
            else
                txtTotalPPN_B2.BackColor = Color.White;

            if (String.IsNullOrEmpty(txtTotalPPnBM_B2.Text) || long.Parse(txtTotalPPnBM_B2.Text) != ppnbm3)
            {
                txtTotalPPnBM_B2.BackColor = Color.Red;
                a = false;
            }
            else
                txtTotalPPnBM_B2.BackColor = Color.White;

            for (int i = 0; i <= dgv_1111_B3.RowCount - 1; i++)
            {
                dpp4 += String.IsNullOrEmpty(dgv_1111_B3.Rows[i].Cells[5].Value.ToString()) ? 0 : long.Parse(dgv_1111_B3.Rows[i].Cells[5].Value.ToString());
                ppn4 += String.IsNullOrEmpty(dgv_1111_B3.Rows[i].Cells[6].Value.ToString()) ? 0 : long.Parse(dgv_1111_B3.Rows[i].Cells[6].Value.ToString());
                ppnbm4 += String.IsNullOrEmpty(dgv_1111_B3.Rows[i].Cells[7].Value.ToString()) ? 0 : long.Parse(dgv_1111_B3.Rows[i].Cells[7].Value.ToString());
            }

            if (String.IsNullOrEmpty(txtTotalDPP_B3.Text) || long.Parse(txtTotalDPP_B3.Text) != dpp4)
            {
                txtTotalDPP_B3.BackColor = Color.Red;
                a = false;
            }
            else
                txtTotalDPP_B3.BackColor = Color.White;

            if (String.IsNullOrEmpty(txtTotalPPN_B3.Text) || long.Parse(txtTotalPPN_B3.Text) != ppn4)
            {
                txtTotalPPN_B3.BackColor = Color.Red;
                a = false;
            }
            else
                txtTotalPPN_B3.BackColor = Color.White;

            if (String.IsNullOrEmpty(txtTotalPPnBM_B3.Text) || long.Parse(txtTotalPPnBM_B3.Text) != ppnbm4)
            {
                txtTotalPPnBM_B3.BackColor = Color.Red;
                a = false;
            }
            else
                txtTotalPPnBM_B3.BackColor = Color.White;

            if (String.IsNullOrEmpty(txt_Page2_I_A.Text) || (!String.IsNullOrEmpty(txtTotalDPP_A1.Text) &&
                long.Parse(txt_Page2_I_A.Text) != long.Parse(txtTotalDPP_A1.Text)))
            {
                txt_Page2_I_A.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page2_I_B_1_DPP.Text) || (!String.IsNullOrEmpty(txtTotalDPP_A2.Text) &&
                long.Parse(txt_Page2_I_B_1_DPP.Text) != long.Parse(txtTotalDPP_A2.Text)))
            {
                txt_Page2_I_B_1_DPP.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page2_I_B_1_PPN.Text) || (!String.IsNullOrEmpty(txtTotalPPN_A2.Text) &&
                long.Parse(txt_Page2_I_B_1_PPN.Text) != long.Parse(txtTotalPPN_A2.Text)))
            {
                txt_Page2_I_B_1_PPN.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page2_I_B_1_PPnBM.Text) || (!String.IsNullOrEmpty(txtTotalPPnBM_A2.Text) &&
                long.Parse(txt_Page2_I_B_1_PPnBM.Text) != long.Parse(txtTotalPPnBM_A2.Text)))
            {
                txt_Page2_I_B_1_PPnBM.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page2_I_B_2_DPP.Text))
            {
                txt_Page2_I_B_2_DPP.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page2_I_B_2_PPN.Text))
            {
                txt_Page2_I_B_2_PPN.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page2_I_B_2_PPnBM.Text))
            {
                txt_Page2_I_B_2_PPnBM.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page2_I_C_1_DPP.Text) || (!String.IsNullOrEmpty(txt_Page2_I_B_2_DPP.Text) &&
                long.Parse(txt_Page2_I_C_1_DPP.Text) != long.Parse(txt_Page2_I_B_2_DPP.Text) + jml1_dpp))
            {
                txt_Page2_I_C_1_DPP.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page2_I_C_1_PPN.Text) || (!String.IsNullOrEmpty(txt_Page2_I_B_2_PPN.Text) &&
                long.Parse(txt_Page2_I_C_1_PPN.Text) != long.Parse(txt_Page2_I_B_2_PPN.Text) + jml1_ppn))
            {
                txt_Page2_I_C_1_PPN.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page2_I_C_1_PPnBM.Text) || (!String.IsNullOrEmpty(txt_Page2_I_B_2_PPnBM.Text) &&
                long.Parse(txt_Page2_I_C_1_PPnBM.Text) != long.Parse(txt_Page2_I_B_2_PPnBM.Text) + jml1_ppnbm))
            {
                txt_Page2_I_C_1_PPnBM.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page2_I_C_2_DPP.Text) || (long.Parse(txt_Page2_I_C_2_DPP.Text) != jml2_dpp))
            {
                txt_Page2_I_C_2_DPP.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page2_I_C_2_PPN.Text) || (long.Parse(txt_Page2_I_C_2_PPN.Text) != jml2_ppn))
            {
                txt_Page2_I_C_2_PPN.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page2_I_C_2_PPnBM.Text) || (long.Parse(txt_Page2_I_C_2_PPnBM.Text) != jml2_ppnbm))
            {
                txt_Page2_I_C_2_PPnBM.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page2_I_C_3_DPP.Text) || (long.Parse(txt_Page2_I_C_3_DPP.Text) != jml3_dpp))
            {
                txt_Page2_I_C_3_DPP.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page2_I_C_3_PPN.Text) || (long.Parse(txt_Page2_I_C_3_PPN.Text) != jml3_ppn))
            {
                txt_Page2_I_C_3_PPN.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page2_I_C_3_PPnBM.Text) || (long.Parse(txt_Page2_I_C_3_PPnBM.Text) != jml3_ppnbm))
            {
                txt_Page2_I_C_3_PPnBM.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page2_I_C_4_DPP.Text) || (long.Parse(txt_Page2_I_C_4_DPP.Text) != jml4_dpp))
            {
                txt_Page2_I_C_4_DPP.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page2_I_C_4_PPN.Text) || (long.Parse(txt_Page2_I_C_4_PPN.Text) != jml4_ppn))
            {
                txt_Page2_I_C_4_PPN.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page2_I_C_4_PPnBM.Text) || (long.Parse(txt_Page2_I_C_4_PPnBM.Text) != jml4_ppnbm))
            {
                txt_Page2_I_C_4_PPnBM.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page2_II_A_DPP.Text) || (!String.IsNullOrEmpty(txtTotalDPP_B1.Text) && 
                long.Parse(txt_Page2_II_A_DPP.Text) != long.Parse(txtTotalDPP_B1.Text)))
            {
                txt_Page2_II_A_DPP.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page2_II_A_PPN.Text) || (!String.IsNullOrEmpty(txtTotalPPN_B1.Text) &&
                long.Parse(txt_Page2_II_A_PPN.Text) != long.Parse(txtTotalPPN_B1.Text)))
            {
                txt_Page2_II_A_PPN.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page2_II_A_PPnBM.Text) || (!String.IsNullOrEmpty(txtTotalPPnBM_B1.Text) &&
                long.Parse(txt_Page2_II_A_PPnBM.Text) != long.Parse(txtTotalPPnBM_B1.Text)))
            {
                txt_Page2_II_A_PPnBM.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page2_II_B_DPP.Text) || (!String.IsNullOrEmpty(txtTotalDPP_B2.Text) &&
                long.Parse(txt_Page2_II_B_DPP.Text) != long.Parse(txtTotalDPP_B2.Text)))
            {
                txt_Page2_II_B_DPP.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page2_II_B_PPN.Text) || (!String.IsNullOrEmpty(txtTotalPPN_B2.Text) &&
                long.Parse(txt_Page2_II_B_PPN.Text) != long.Parse(txtTotalPPN_B2.Text)))
            {
                txt_Page2_II_B_PPN.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page2_II_B_PPnBM.Text) || (!String.IsNullOrEmpty(txtTotalPPnBM_B2.Text) &&
                long.Parse(txt_Page2_II_B_PPnBM.Text) != long.Parse(txtTotalPPnBM_B2.Text)))
            {
                txt_Page2_II_B_PPnBM.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page2_II_C_DPP.Text) || (!String.IsNullOrEmpty(txtTotalDPP_B3.Text) &&
                long.Parse(txt_Page2_II_C_DPP.Text) != long.Parse(txtTotalDPP_B3.Text)))
            {
                txt_Page2_II_C_DPP.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page2_II_C_PPN.Text) || (!String.IsNullOrEmpty(txtTotalPPN_B3.Text) &&
                long.Parse(txt_Page2_II_C_PPN.Text) != long.Parse(txtTotalPPN_B3.Text)))
            {
                txt_Page2_II_C_PPN.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page2_II_C_PPnBM.Text) || (!String.IsNullOrEmpty(txtTotalPPnBM_B3.Text) &&
                long.Parse(txt_Page2_II_C_PPnBM.Text) != long.Parse(txtTotalPPnBM_B3.Text)))
            {
                txt_Page2_II_C_PPnBM.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page2_II_D_DPP.Text)||
               (!String.IsNullOrEmpty(txt_Page2_II_A_DPP.Text) && !String.IsNullOrEmpty(txt_Page2_II_B_DPP.Text) &&
               !String.IsNullOrEmpty(txt_Page2_II_C_DPP.Text) &&
               long.Parse(txt_Page2_II_D_DPP.Text) != long.Parse(txt_Page2_II_A_DPP.Text) + long.Parse(txt_Page2_II_B_DPP.Text) + long.Parse(txt_Page2_II_C_DPP.Text)))
            {
                txt_Page2_II_D_DPP.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page2_II_D_PPN.Text) ||
               (!String.IsNullOrEmpty(txt_Page2_II_A_PPN.Text) && !String.IsNullOrEmpty(txt_Page2_II_B_PPN.Text) &&
               !String.IsNullOrEmpty(txt_Page2_II_C_PPN.Text) &&
               long.Parse(txt_Page2_II_D_PPN.Text) != long.Parse(txt_Page2_II_A_PPN.Text) + long.Parse(txt_Page2_II_B_PPN.Text) + long.Parse(txt_Page2_II_C_PPN.Text)))
            {
                txt_Page2_II_D_PPN.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page2_II_D_PPnBM.Text) ||
               (!String.IsNullOrEmpty(txt_Page2_II_A_PPnBM.Text) && !String.IsNullOrEmpty(txt_Page2_II_B_PPnBM.Text) &&
               !String.IsNullOrEmpty(txt_Page2_II_C_PPnBM.Text) &&
               long.Parse(txt_Page2_II_D_PPnBM.Text) != long.Parse(txt_Page2_II_A_PPnBM.Text) + long.Parse(txt_Page2_II_B_PPnBM.Text) + long.Parse(txt_Page2_II_C_PPnBM.Text)))
            {
                txt_Page2_II_D_PPnBM.BackColor = Color.Red;
                a = false;
            }
            if (String.IsNullOrEmpty(txt_Page2_III_A.Text) ||
               (!String.IsNullOrEmpty(txt_Page2_II_A_PPN.Text) && !String.IsNullOrEmpty(txt_Page2_II_B_PPN.Text) &&
               long.Parse(txt_Page2_III_A.Text) != long.Parse(txt_Page2_II_A_PPN.Text) + long.Parse(txt_Page2_II_B_PPN.Text)))
            {
                txt_Page2_III_A.BackColor = Color.Red;
                a = false;
            }

            if (String.IsNullOrEmpty(txt_Page2_III_B_1.Text))
            {
                txt_Page2_III_B_1.BackColor = Color.Red;
                 a = false;
            }
            if (String.IsNullOrEmpty(txt_Page2_III_B_2.Text))
            {
                txt_Page2_III_B_2.BackColor = Color.Red;
                 a = false;
            }
            if (String.IsNullOrEmpty(txt_Page2_III_B_3.Text))
            {
                txt_Page2_III_B_3.BackColor = Color.Red;
                 a = false;
            }
            if (String.IsNullOrEmpty(txt_Page2_III_B_4.Text) ||
               (!String.IsNullOrEmpty(txt_Page2_III_B_1.Text) && !String.IsNullOrEmpty(txt_Page2_III_B_2.Text) &&
               !String.IsNullOrEmpty(txt_Page2_III_B_3.Text) &&
               long.Parse(txt_Page2_III_B_4.Text) != long.Parse(txt_Page2_III_B_1.Text) + long.Parse(txt_Page2_III_B_2.Text) + long.Parse(txt_Page2_III_B_3.Text)))
            {
                txt_Page2_III_B_4.BackColor = Color.Red;
                 a = false;
            }
            if (String.IsNullOrEmpty(txt_Page2_III_C.Text) ||
               (!String.IsNullOrEmpty(txt_Page2_III_A.Text) && !String.IsNullOrEmpty(txt_Page2_III_B_4.Text) &&
               long.Parse(txt_Page2_III_C.Text) != long.Parse(txt_Page2_III_A.Text) + long.Parse(txt_Page2_III_B_4.Text)))
            {
                txt_Page2_III_C.BackColor = Color.Red;
                 a = false;
            }

            return a;
        }

        private void SaveData()
        {
            String log = GenerateChanegLog();

            form.I_A_1 = txt_Page1_I_A_1.Text;
            form.I_A_2_DPP = txt_Page1_I_A_2_DPP.Text;
            form.I_A_2_PPN = txt_Page1_I_A_2_PPN.Text;
            form.I_A_3_DPP = txt_Page1_I_A_3_DPP.Text;
            form.I_A_3_PPN = txt_Page1_I_A_3_PPN.Text;
            form.I_A_4_DPP = txt_Page1_I_A_4_DPP.Text;
            form.I_A_4_PPN = txt_Page1_I_A_4_PPN.Text;
            form.I_A_5_DPP = txt_Page1_I_A_5_DPP.Text;
            form.I_A_5_PPN = txt_Page1_I_A_5_PPN.Text;
            form.I_A_Jml_DPP = txt_Page1_I_A_Jml_DPP.Text;
            form.I_A_Jml_PPN = txt_Page1_I_A_Jml_PPN.Text;
            form.I_B = txt_Page1_I_B.Text;
            form.I_C = txt_Page1_I_C.Text;
            form.II_A = txt_Page1_II_A.Text;
            form.II_B = txt_Page1_II_B.Text;
            form.II_C = txt_Page1_II_C.Text;
            form.II_D = txt_Page1_II_D.Text;
            form.II_E = txt_Page1_II_E.Text;
            form.II_F = txt_Page1_II_F.Text;
            form.III_A = txt_Page1_III_A.Text;
            form.III_B = txt_Page1_III_B.Text;
            form.IV_A = txt_Page1_IV_A.Text;
            form.V_A = txt_Page1_V_A.Text;
            form.V_B = txt_Page1_V_B.Text;
            form.V_C = txt_Page1_V_C.Text;
            form.V_D = txt_Page1_V_D.Text;
            form.V_E = txt_Page1_V_E.Text;

            form.A1_Page.TotalDpp = txtTotalDPP_A1.Text;
            form.A2_Page.TotalDpp = txtTotalDPP_A2.Text;
            form.A2_Page.TotalPpn = txtTotalPPN_A2.Text;
            form.A2_Page.TotalPPnBM = txtTotalPPnBM_A2.Text;
            form.B1_Page.TotalDpp = txtTotalDPP_B1.Text;
            form.B1_Page.TotalPpn = txtTotalPPN_B1.Text;
            form.B1_Page.TotalPPnBM = txtTotalPPnBM_B1.Text;
            form.B2_Page.TotalDpp = txtTotalDPP_B2.Text;
            form.B2_Page.TotalPpn = txtTotalPPN_B2.Text;
            form.B2_Page.TotalPPnBM = txtTotalPPnBM_B2.Text;
            form.B3_Page.TotalDpp = txtTotalDPP_B3.Text;
            form.B3_Page.TotalPpn = txtTotalPPN_B3.Text;
            form.B3_Page.TotalPPnBM = txtTotalPPnBM_B3.Text;
            
            foreach (Form1111_Item i in form.A1_Page.Items)
            {
                DataGridViewRow r = GetDataGridViewRowByIdAndDocId(i.Id, i.DocId, dgv_1111_A1);
                if (r != null)
                {
                    i.Dpp = r.Cells[4].Value.ToString();
                }
            }

            foreach (Form1111_Item i in form.A2_Page.Items)
            {
                DataGridViewRow r = GetDataGridViewRowByIdAndDocId(i.Id, i.DocId, dgv_1111_A2);
                if (r != null)
                {
                    i.Dpp = r.Cells[5].Value.ToString();
                    i.Ppn = r.Cells[6].Value.ToString();
                    i.PPnBM = r.Cells[7].Value.ToString();
                }
            }

            foreach (Form1111_Item i in form.B1_Page.Items)
            {
                DataGridViewRow r = GetDataGridViewRowByIdAndDocId(i.Id, i.DocId, dgv_1111_B1);
                if (r != null)
                {
                    i.Dpp = r.Cells[4].Value.ToString();
                    i.Ppn = r.Cells[5].Value.ToString();
                    i.PPnBM = r.Cells[6].Value.ToString();
                }
            }

            foreach (Form1111_Item i in form.B2_Page.Items)
            {
                DataGridViewRow r = GetDataGridViewRowByIdAndDocId(i.Id, i.DocId, dgv_1111_B2);
                if (r != null)
                {
                    i.Dpp = r.Cells[5].Value.ToString();
                    i.Ppn = r.Cells[6].Value.ToString();
                    i.PPnBM = r.Cells[7].Value.ToString();
                }
            }

            foreach (Form1111_Item i in form.B3_Page.Items)
            {
                DataGridViewRow r = GetDataGridViewRowByIdAndDocId(i.Id, i.DocId, dgv_1111_B3);
                if (r != null)
                {
                    i.Dpp = r.Cells[5].Value.ToString();
                    i.Ppn = r.Cells[6].Value.ToString();
                    i.PPnBM = r.Cells[7].Value.ToString();
                }
            }

            form.I_A2 = txt_Page2_I_A.Text;
            form.I_B2_1_DPP = txt_Page2_I_B_1_DPP.Text;
            form.I_B2_1_PPN = txt_Page2_I_B_1_PPN.Text;
            form.I_B2_1_PPnBM = txt_Page2_I_B_1_PPnBM.Text;
            form.I_B2_2_DPP = txt_Page2_I_B_2_DPP.Text;
            form.I_B2_2_PPN = txt_Page2_I_B_2_PPN.Text;
            form.I_B2_2_PPnBM = txt_Page2_I_B_2_PPnBM.Text;
            form.I_C2_1_DPP = txt_Page2_I_C_1_DPP.Text;
            form.I_C2_1_PPN = txt_Page2_I_C_1_PPN.Text;
            form.I_C2_1_PPnBM = txt_Page2_I_C_1_PPnBM.Text;
            form.I_C2_2_DPP = txt_Page2_I_C_2_DPP.Text;
            form.I_C2_2_PPN = txt_Page2_I_C_2_PPN.Text;
            form.I_C2_2_PPnBM = txt_Page2_I_C_2_PPnBM.Text;
            form.I_C2_3_DPP = txt_Page2_I_C_3_DPP.Text;
            form.I_C2_3_PPN = txt_Page2_I_C_3_PPN.Text;
            form.I_C2_3_PPnBM = txt_Page2_I_C_3_PPnBM.Text;
            form.I_C2_4_DPP = txt_Page2_I_C_4_DPP.Text;
            form.I_C2_4_PPN = txt_Page2_I_C_4_PPN.Text;
            form.I_C2_4_PPnBM = txt_Page2_I_C_4_PPnBM.Text;
            
            form.II_A2_DPP = txt_Page2_II_A_DPP.Text;
            form.II_A2_PPN = txt_Page2_II_A_PPN.Text;
            form.II_A2_PPnBM = txt_Page2_II_A_PPnBM.Text;
            form.II_B2_DPP = txt_Page2_II_B_DPP.Text;
            form.II_B2_PPN = txt_Page2_II_B_PPN.Text;
            form.II_B2_PPnBM = txt_Page2_II_B_PPnBM.Text;
            form.II_C2_DPP = txt_Page2_II_C_DPP.Text;
            form.II_C2_PPN = txt_Page2_II_C_PPN.Text;
            form.II_C2_PPnBM = txt_Page2_II_C_PPnBM.Text;
            form.II_D2_DPP = txt_Page2_II_D_DPP.Text;
            form.II_D2_PPN = txt_Page2_II_D_PPN.Text;
            form.II_D2_PPnBM = txt_Page2_II_D_PPnBM.Text;

            form.III_A2 = txt_Page2_III_A.Text;
            form.III_B2_1 = txt_Page2_III_B_1.Text;
            form.III_B2_2 = txt_Page2_III_B_2.Text;
            form.III_B2_3 = txt_Page2_III_B_3.Text;
            form.III_B2_4 = txt_Page2_III_B_4.Text;
            form.III_C2 = txt_Page2_III_C.Text;
            
            QAController.UpdateForm1111(this.form, log);
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }

        private DataGridViewRow GetDataGridViewRowByIdAndDocId(string Id, string docId, QAControl.QADataGrid dataGrid)
        {
            foreach (DataGridViewRow r in dataGrid.Rows)
                if (r.Cells[dataGrid.ColumnCount-1].Value.Equals(Id) && r.Cells[0].Value.Equals(docId))
                    return r;
            return null;
        }

        private string GenerateChanegLog()
        {
            StringBuilder sbLog = new StringBuilder();
            foreach (Control c in tbp1111.Controls)
            {
                QATextbox qt = c as QATextbox;
                if (qt != null && qt.Text != qt.OriginalValue)
                    sbLog.AppendLine(qt.Name.Replace("txt_Page1_", "") + ": " + qt.OriginalValue + " -> " + qt.Text);
            }

            foreach (DataGridViewRow r in dgv_1111_A1.Rows)
            {
                string dppCurrent = r.Cells[COL_DPP].Value.ToString();
                string dppOri = r.Cells[COL_DPP_ORI].Value.ToString();
                if (dppCurrent != dppOri)
                    sbLog.AppendLine("DPP_A1 milik " + r.Cells[COL_NAMA_PEMBELI].Value + ": " + dppOri + " -> " + dppCurrent);

            }

            foreach (Control c in tbp1111_A1.Controls)
            {
                QATextbox qt = c as QATextbox;
                if (qt != null && qt.Text != qt.OriginalValue)
                    sbLog.AppendLine(qt.Name.Replace("txt", "").Replace("_A1", "") + ": " + qt.OriginalValue + " -> " + qt.Text);
            }


            foreach (DataGridViewRow r in dgv_1111_A2.Rows)
            {
                string dppCurrent = r.Cells[COL_DPP].Value.ToString();
                string dppOri = r.Cells[COL_DPP_ORI].Value.ToString();
                if (dppCurrent != dppOri)
                    sbLog.AppendLine("DPP_A2 milik " + r.Cells[COL_NAMA_PEMBELI].Value + ": " + dppOri + " -> " + dppCurrent);

                string ppnCurrent = r.Cells[COL_PPN].Value.ToString();
                string ppnOri = r.Cells[COL_PPN_ORI].Value.ToString();
                if (ppnCurrent != ppnOri)
                    sbLog.AppendLine("PPN_A2 milik " + r.Cells[COL_NAMA_PEMBELI].Value + ": " + ppnOri + " -> " + ppnCurrent);

                string ppnbmCurrent = r.Cells[COL_PPNBM].Value.ToString();
                string ppnbmOri = r.Cells[COL_PPNBM_ORI].Value.ToString();
                if (ppnbmCurrent != ppnbmOri)
                    sbLog.AppendLine("PPnBM_A2 milik " + r.Cells[COL_NAMA_PEMBELI].Value + ": " + ppnbmOri + " -> " + ppnbmCurrent);

            }

            foreach (Control c in tbp1111_A2.Controls)
            {
                QATextbox qt = c as QATextbox;
                if (qt != null && qt.Text != qt.OriginalValue)
                    sbLog.AppendLine(qt.Name.Replace("txt", "").Replace("_A2", "") + ": " + qt.OriginalValue + " -> " + qt.Text);
            }


            foreach (DataGridViewRow r in dgv_1111_B1.Rows)
            {
                string dppCurrent = r.Cells[COL_DPP].Value.ToString();
                string dppOri = r.Cells[COL_DPP_ORI].Value.ToString();
                if (dppCurrent != dppOri)
                    sbLog.AppendLine("DPP_B1 milik " + r.Cells[COL_NAMA_PEMBELI].Value + ": " + dppOri + " -> " + dppCurrent);

                string ppnCurrent = r.Cells[COL_PPN].Value.ToString();
                string ppnOri = r.Cells[COL_PPN_ORI].Value.ToString();
                if (ppnCurrent != ppnOri)
                    sbLog.AppendLine("PPN_B1 milik " + r.Cells[COL_NAMA_PEMBELI].Value + ": " + ppnOri + " -> " + ppnCurrent);

                string ppnbmCurrent = r.Cells[COL_PPNBM].Value.ToString();
                string ppnbmOri = r.Cells[COL_PPNBM_ORI].Value.ToString();
                if (ppnbmCurrent != ppnbmOri)
                    sbLog.AppendLine("PPnBM_B1 milik " + r.Cells[COL_NAMA_PEMBELI].Value + ": " + ppnbmOri + " -> " + ppnbmCurrent);

            }

            foreach (Control c in tbp1111_B1.Controls)
            {
                QATextbox qt = c as QATextbox;
                if (qt != null && qt.Text != qt.OriginalValue)
                    sbLog.AppendLine(qt.Name.Replace("txt", "").Replace("_B1", "") + ": " + qt.OriginalValue + " -> " + qt.Text);
            }


            foreach (DataGridViewRow r in dgv_1111_B2.Rows)
            {
                string dppCurrent = r.Cells[COL_DPP].Value.ToString();
                string dppOri = r.Cells[COL_DPP_ORI].Value.ToString();
                if (dppCurrent != dppOri)
                    sbLog.AppendLine("DPP_B2 milik " + r.Cells[COL_NAMA_PEMBELI].Value + ": " + dppOri + " -> " + dppCurrent);

                string ppnCurrent = r.Cells[COL_PPN].Value.ToString();
                string ppnOri = r.Cells[COL_PPN_ORI].Value.ToString();
                if (ppnCurrent != ppnOri)
                    sbLog.AppendLine("PPN_B2 milik " + r.Cells[COL_NAMA_PEMBELI].Value + ": " + ppnOri + " -> " + ppnCurrent);

                string ppnbmCurrent = r.Cells[COL_PPNBM].Value.ToString();
                string ppnbmOri = r.Cells[COL_PPNBM_ORI].Value.ToString();
                if (ppnbmCurrent != ppnbmOri)
                    sbLog.AppendLine("PPnBM_B2 milik " + r.Cells[COL_NAMA_PEMBELI].Value + ": " + ppnbmOri + " -> " + ppnbmCurrent);

            }

            foreach (Control c in tbp1111_B2.Controls)
            {
                QATextbox qt = c as QATextbox;
                if (qt != null && qt.Text != qt.OriginalValue)
                    sbLog.AppendLine(qt.Name.Replace("txt", "").Replace("_B2", "") + ": " + qt.OriginalValue + " -> " + qt.Text);
            }


            foreach (DataGridViewRow r in dgv_1111_B3.Rows)
            {
                string dppCurrent = r.Cells[COL_DPP].Value.ToString();
                string dppOri = r.Cells[COL_DPP_ORI].Value.ToString();
                if (dppCurrent != dppOri)
                    sbLog.AppendLine("DPP_B3 milik " + r.Cells[COL_NAMA_PEMBELI].Value + ": " + dppOri + " -> " + dppCurrent);

                string ppnCurrent = r.Cells[COL_PPN].Value.ToString();
                string ppnOri = r.Cells[COL_PPN_ORI].Value.ToString();
                if (ppnCurrent != ppnOri)
                    sbLog.AppendLine("PPN_B3 milik " + r.Cells[COL_NAMA_PEMBELI].Value + ": " + ppnOri + " -> " + ppnCurrent);

                string ppnbmCurrent = r.Cells[COL_PPNBM].Value.ToString();
                string ppnbmOri = r.Cells[COL_PPNBM_ORI].Value.ToString();
                if (ppnbmCurrent != ppnbmOri)
                    sbLog.AppendLine("PPnBM_B3 milik " + r.Cells[COL_NAMA_PEMBELI].Value + ": " + ppnbmOri + " -> " + ppnbmCurrent);

            }

            foreach (Control c in tbp1111_B3.Controls)
            {
                QATextbox qt = c as QATextbox;
                if (qt != null && qt.Text != qt.OriginalValue)
                    sbLog.AppendLine(qt.Name.Replace("txt", "").Replace("_B3", "") + ": " + qt.OriginalValue + " -> " + qt.Text);
            }

            foreach (Control c in tbp1111_AB.Controls)
            {
                QATextbox qt = c as QATextbox;
                if (qt != null && qt.Text != qt.OriginalValue)
                    sbLog.AppendLine(qt.Name.Replace("txt_Page2_", "") + ": " + qt.OriginalValue + " -> " + qt.Text);
            }

            return sbLog.ToString();
        }

        private void SetDataGridBackgroundColor(QAControl.QABaseDataGrid dataGrid, int jml)
        {
            foreach (DataGridViewRow row in dataGrid.Rows)
            {
                for (int i = 1; i <= jml; i++)
                {
                    if (!row.Cells[i].Value.Equals(row.Cells[i + jml].Value))

                        row.Cells[i].Style.BackColor = Color.LightGreen;
                    else
                        row.Cells[i].Style.BackColor = Color.White;
                }
            }

            dataGrid.ClearSelection();
        }
    }
}
